home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_10_07
/
1007014a
< prev
next >
Wrap
Text File
|
1992-05-03
|
485b
|
24 lines
Listing 3 -- mbstowcs.c
/* mbstowcs function */
#include <stdlib.h>
size_t (mbstowcs)(wchar_t *wcs, const char *s, size_t n)
{ /* translate multibyte string to wide char string */
int i;
wchar_t *pwc;
_Mbsave state = {0};
for (pwc = wcs; 0 < n; ++pwc, --n)
{ /* make another wide character */
i = _Mbtowc(pwc, s, n, &state);
if (i == -1)
return (-1);
else if (i == 0 || *pwc == 0)
return (pwc - wcs);
s += i;
}
return (pwc - wcs);
}